home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 2: CDPD 1 / Almathera Ten on Ten - Disc 2: CDPD 1.iso / pd / 126-150 / 141 / smallc / syntax.doc < prev    next >
Text File  |  1995-03-13  |  5KB  |  147 lines

  1.  
  2.        The compiler supports the following:
  3.  
  4.          1.  Data type declarations:
  5.  
  6.                char            8-bits
  7.                int             32-bits
  8.                extern char     external 8-bits
  9.                extern int      external 32-bits
  10.  
  11.                A pointer to either of these types is declared by placing an
  12.                asterisk "*" before the pointer name.  A pointer is a 32-bit
  13.                stack offset.
  14.  
  15.          2.  Arrays must be single dimension (vector) structures of type
  16.              char or int.
  17.  
  18.          3.  Expressions:
  19.                unary operators:
  20.                  "-"     minus
  21.                  "*"     indirection
  22.                  "&"     address of scalar
  23.                  "++"    increment, either prefix or postfix
  24.                  "--"    decrement, either prefix or postfix
  25.  
  26.                binary operators:
  27.                  "+"     addition
  28.                  "-"     subtraction
  29.                  "*"     multiplication
  30.                  "/"     division
  31.                  "%"     mod, i.e. remainder from division
  32.                  "|"     inclusive or
  33.                  "^"     exclusive or
  34.                  "&"     logical and
  35.                  "=="    test for equality
  36.                  "!="    test for inequality
  37.                  "<"     test for less than
  38.                  "<="    test for less or equal
  39.                  ">"     test for greater than
  40.                  ">="    test for greater or equal
  41.                  "<<"    arithmetic shift left
  42.                  ">>"    arithmetic shift right
  43.                  "="     assignment
  44.  
  45.                primaries:
  46.                  array[expression]
  47.                  function(arg1,...,argn)
  48.                  constants:
  49.                    decimal number
  50.                    quoted string ("sample")
  51.                    primed string ('a' or '10')
  52.                  local variable (or pointer)
  53.                  global (static) variable (or pointer)
  54.  
  55.          4.  Program control:
  56.                if(expression) statement;
  57.                if(expression) statement;
  58.                    else statement;
  59.                while (expression) statement;
  60.                break;
  61.                continue;
  62.                return;
  63.                return expression;
  64.                ; (null statement)
  65.                compound statement:
  66.                {statement1; statement2;...;statementn;}
  67.  
  68.          5.  Pointers
  69.                local and static pointers can contain the
  70.                address of "char" or "int" data items.
  71.  
  72.          6.  Compiler commands:
  73.                #define name string
  74.                  (preprocessor will replace name by string
  75.                   throughout the program text)
  76.                #include filename
  77.                  (Input is suspended from the input filename and
  78.                   text is read from the file named in the include
  79.                   statement.  When end-of-file is detected, input
  80.                   is resumed from the input filename.  A separate
  81.                   output file is not created for the #include file
  82.                   Its output is directed to the currently open
  83.                   output file.)
  84.                #asm
  85.                #endasm
  86.  
  87.          7.  Miscellaneous notes:
  88.  
  89.                Expression evaluation maintains the same hierarchy as
  90.                standard C.
  91.  
  92.                Function calls are defined as any primary followed by
  93.                an open parenthesis.  Legal forms include:
  94.                  variable();
  95.                  array[expression]();
  96.                  constant();
  97.                  function() ();
  98.  
  99.                NOTE:  the various function call forms are not supported
  100.                       in standard C.
  101.  
  102.                Pointer arithmetic takes into account the data type the
  103.                pointer was declared for (e.g. ptr++ will increment by 4
  104.                if declared "int *ptr;").
  105.  
  106.                Pointers are compared as unsigned 32-bit values.
  107.  
  108.                The generated code is reentrant.  Since local variables are
  109.                allocated on the stack, each new invocation of a function
  110.                generates a new copy of local variables.
  111.  
  112.        The compiler does not support:
  113.  
  114.          1.  Structures and unions
  115.  
  116.          2.  Multi-dimensional arrays
  117.  
  118.          3.  Floating point data
  119.  
  120.          4.  Long integers
  121.  
  122.          5.  Functions that return anything but "int" values
  123.  
  124.          6.  Unary operators:
  125.                "!"
  126.                "~"
  127.                "sizeof"
  128.                casts
  129.  
  130.          7.  The operators:
  131.                "&&"
  132.                "||"
  133.                "?:"
  134.                ","
  135.  
  136.          8.  Assignment operators:
  137.                +=
  138.                -=
  139.                *=
  140.                /=
  141.                %=
  142.                >>=
  143.                <<=
  144.                &=
  145.                ^=
  146.                |=
  147.